package org.yangjie.service;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import org.springframework.stereotype.Service;

@Service
public class AuthService {
	
	// 模拟token存储
	private Map<String, String> tokenMap = new HashMap<>();
	
	
	/**
	 * 模拟用户认证成功, 返回token
	 * @return
	 */
	public String auth() {
		String token = UUID.randomUUID().toString().replace("-", "");
		tokenMap.put(token, "USER"); // 缓存角色/权限列表
		return token;
	}

	/**
	 * 获取
	 * @param token
	 * @return
	 */
	public String get(String token) {
		return tokenMap.get(token);
	}
	
}
